@extends('admin.layouts.base')

@section('title','控制面板')

@section('pageHeader','控制面板')

@section('pageDesc','DashBoard')

@section('content')

    <div class="row page-title-row" style="margin:5px;">
        <div class="col-md-6">
			<!--<a href="/admin/chart" class="btn btn-success btn-md">
                <i class="fa fa-bar-chart-o"></i> 图形统计
            </a>-->
			
			<a href="/admin/originate/table" class="btn btn-success btn-md">
                <i class="fa fa-table"></i> 表格统计
            </a>
        </div>
        <div class="col-md-6 text-right">
            <a href="/admin/originate/0/edit" target="_blank" class="btn btn-success btn-md">
                <i class="glyphicon glyphicon-equalizer"></i> 分列来源
            </a>
        </div>
    </div>
    <div class="row page-title-row" style="margin:5px;">
        <div class="col-md-6">
        </div>
        <div class="col-md-6 text-right">
        </div>
    </div>

    <div class="row">
        <div class="col-xs-12">
            <div class="box">

                @include('admin.partials.errors')
                @include('admin.partials.success')
                <div class="box-body">
                    <table id="tags-table" class="table table-bordered table-hover">
                        <thead>
                        <tr>
                            <th class="hidden-sm">站点名称</th>
                            <th class="hidden-sm">微信</th>
							<th class="hidden-md">点击事件</th>
							<th class="hidden-md">渠道</th>
							<th class="hidden-md">媒介</th>
							<th class="hidden-md">广告名称</th>
							<th class="hidden-md">广告内容</th>
							<th class="hidden-md">关键词</th>
							<th class="hidden-md">终端</th>
							<th class="hidden-md">是否在微信内</th>
							<th class="hidden-md">形式</th>
                            <th class="hidden-md">城市</th>
							<th class="hidden-md">浏览器类型</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    </div>
    </div>

@stop

@section('js')
    <script>
        $(function () {
            var table = $("#tags-table").DataTable({
                language: {
                    "sProcessing": "处理中...",
                    "sLengthMenu": "显示 _MENU_ 项结果",
                    "sZeroRecords": "没有匹配结果",
                    "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                    "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
                    "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
                    "sInfoPostFix": "",
                    "sSearch": "搜索:",
                    "sUrl": "",
                    "sEmptyTable": "表中数据为空",
                    "sLoadingRecords": "载入中...",
                    "sInfoThousands": ",",
                    "oPaginate": {
                        "sFirst": "首页",
                        "sPrevious": "上页",
                        "sNext": "下页",
                        "sLast": "末页"
                    },
                    "oAria": {
                        "sSortAscending": ": 以升序排列此列",
                        "sSortDescending": ": 以降序排列此列"
                    }
                },
				"iDisplayLength": 100,
                order: [[0, "desc"]],
                serverSide: true,
                ajax: {
                    url: '/admin/originate/index',
                    type: 'POST',
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                    }
                },
                "columns": [
                    {"data": "site_name",render:function(data){ return "<div style='text-overflow:ellipsis;overflow:hidden;white-space:nowrap;width:130px;'>"+data+"</div>"; }},
                    {"data": "wechat"},
                    {"data": "touch"},
                    {"data": "channel"},
					{"data": "medium"},
                    {"data": "adverti_name"},
                    {"data": "adverti_content"},
                    {"data": "keyword"},
                    {"data": "terminal"},
                    {"data": "in_wechat",render:function(data){ if(data==1)return "是"; else return "否";}},
                    {"data": "adverti_type",render:function(data){
						switch(data){
							case 1:
								return "微信号";
							default:
								return "未知";
						}
					}},
					{"data": "city"},
                    {"data": "user_agent",render:function(data){ return "<div style='text-overflow:ellipsis;overflow:hidden;white-space:nowrap;width:130px;'>"+data+"</div>"; }}
                ],
                columnDefs: [
                    /* {
                        'targets': -1, "render": function (data, type, row) {
                        var caozuo = '<a style="margin:3px;" href="/admin/originate/' + row['id'] + '/edit" class="X-Small btn-xs text-success "><i class="fa fa-edit"></i> 编辑</a>';
                        caozuo += '<a style="margin:3px;" href="#" attr="' + row['id'] + '" class="delBtn X-Small btn-xs text-danger "><i class="fa fa-times-circle-o"></i> 删除</a>';
                        return caozuo;
                    }
                    },
                    {
                        'targets': 0, "render": function (data, type, row) {
                        var caozuoCB = '<div class="checkbox hidden-sm"><label><input class="itemCB" name="itemCB[]" type="checkbox" value="' + row['id'] + '"></label><input type="hidden" id="batchDelFormAction" value="/admin/originate"><input type="hidden" id="tipTitle" value="用户"></div>';
                        return caozuoCB;
                    }
                    } */
                ]
            });

            table.on('preXhr.dt', function () {
                loadShow();
            });

            table.on('draw.dt', function () {
                loadFadeOut();
            });

            table.on('order.dt search.dt', function () {
                /* table.column(1, {search: 'applied', order: 'applied'}).nodes().each(function (cell, i) {
                    cell.innerHTML = i + 1;
                }); */
            }).draw();

            $("table").delegate('.delBtn', 'click', function () {
                var id = $(this).attr('attr');
                $('.deleteForm').attr('action', '/admin/originate/' + id);
                $("#modal-delete").modal();
            });

        });
    </script>
@stop